﻿@model XRM.Security.WebUI.Models.UserRegister.UserRegisterModel
@{
    Layout = null;
}

@using (Html.BeginForm("AddUserRegisterChoice", "UserRegister", FormMethod.Post, new { id = "dlgAddUserRegisterDialogForm", @class = "form-horizontal form-horizontal-2" }))
{      
        @Html.AntiForgeryToken()
    const string inputCss = "form-control";
    const string divCss = "col-sm-6";
        @Html.HiddenFor(m => m.Id)
    if ( ViewData.ModelState["FullName"] != null && ViewData.ModelState["FullName"].Errors.Any())
    {
        <div class="alert alert-danger">
            @ViewData.ModelState["FullName"].Errors[0].ErrorMessage
        </div>
    }
                <div class="form-group">
                    @Html.LabelFor(m => m.LastName, new { @class = "control-label required" })
                    <div class="@divCss">
                        @Html.TextBoxFor(m => m.LastName, new { @class = @inputCss })
                        @Html.ValidationMessageFor(m => m.LastName)
                    </div>
                </div>
                <div class="form-group">
                    @Html.LabelFor(m => m.FirstName, new { @class = "control-label required" })
                    <div class="@divCss">
                        @Html.TextBoxFor(m => m.FirstName, new { @class = @inputCss })
                        @Html.ValidationMessageFor(m => m.FirstName)
                    </div>
                </div>
                <div class="form-group">
                    @Html.LabelFor(m => m.MotherName, new { @class = "control-label" })
                    <div class="@divCss">
                        @Html.TextBoxFor(m => m.MotherName, new { @class = @inputCss })
                        @Html.ValidationMessageFor(m => m.MotherName)
                    </div>
                </div>
        
                <div class="form-group">
                    @Html.LabelFor(m => m.DepartmentId, new { @class = "control-label" })
                    <div class="@divCss">
                        @Html.DropDownListFor(m => m.DepartmentId, Model.DepartmentAllList, new { @class = @inputCss })
                        @Html.ValidationMessageFor(m => m.DepartmentId)
                    </div>
                </div>

                <div class="form-group">
                    @Html.LabelFor(m => m.Post, new { @class = "control-label" })
                    <div class="@divCss">
                        @Html.TextBoxFor(m => m.Post, new { @class = @inputCss })
                        @Html.ValidationMessageFor(m => m.Post)
                    </div>
                </div>
        
                <div class="form-group">
                    @Html.LabelFor(m => m.DepartmentAddressId, new { @class = "control-label" })
                    <div class="@divCss">
                        @Html.DropDownListFor(m => m.DepartmentAddressId, Model.DepartmentAddressAllList, new { @class = @inputCss, disabled = "disabled" })
                        @Html.ValidationMessageFor(m => m.DepartmentAddressId)
                    </div>
                </div>

                <div class="form-group">
                    @Html.LabelFor(m => m.Status, new { @class = "control-label required" })
                    <div class="@divCss">
                        @Html.DropDownListFor(m => m.Status, new SelectList(Model.StatusList, "Value", "Text"), new { @class = @inputCss })
                    </div>
                </div>

                <div class="form-group">
                    @Html.LabelFor(m => m.Account, new { @class = "control-label" })
                    <div class="@divCss">
                        @Html.TextBoxFor(m => m.Account, new { @class = @inputCss })
                        @Html.ValidationMessageFor(m => m.Account)
                    </div>
                </div>
    <hr/>
    <div>
        <button type="submit" class="btn btn-primary" id="btnChoiseADUser">Выбрать</button>
        <button type="button" class="btn btn-default" data-dismiss="modal">Отмена</button>
    </div>      
}    

<script type="text/javascript" src="@(Url.Content("~/Scripts/AjaxRequest.js"))"></script>        
<script type="text/javascript">
    $(document).ready(function () {
        $('#DepartmentId').change(function () {
            GetDepartmentAddress();
        });

        $('#btnCancel').on('click', function () { CloseDialog(); });
    });
</script>
